package com.example.arcapplication.db;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.example.arcapplication.bean.DataList;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DATA_LIST".
*/
public class DataListDao extends AbstractDao<DataList, Void> {

    public static final String TABLENAME = "DATA_LIST";

    /**
     * Properties of entity DataList.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Did = new Property(0, Long.class, "did", false, "DID");
        public final static Property Hgsl = new Property(1, String.class, "hgsl", false, "HGSL");
        public final static Property Invcode = new Property(2, String.class, "invcode", false, "INVCODE");
        public final static Property Invname = new Property(3, String.class, "invname", false, "INVNAME");
        public final static Property Ggxh = new Property(4, String.class, "ggxh", false, "GGXH");
        public final static Property Pch = new Property(5, String.class, "pch", false, "PCH");
        public final static Property Gyspch = new Property(6, String.class, "gyspch", false, "GYSPCH");
        public final static Property Bstockid = new Property(7, String.class, "bstockid", false, "BSTOCKID");
        public final static Property Bstockname = new Property(8, String.class, "bstockname", false, "BSTOCKNAME");
        public final static Property Bhwid = new Property(9, String.class, "bhwid", false, "BHWID");
        public final static Property Bhwname = new Property(10, String.class, "bhwname", false, "BHWNAME");
        public final static Property Meaname = new Property(11, String.class, "meaname", false, "MEANAME");
        public final static Property Ddnum = new Property(12, String.class, "ddnum", false, "DDNUM");
        public final static Property Totalarrnum = new Property(13, String.class, "totalarrnum", false, "TOTALARRNUM");
        public final static Property Totalstocknum = new Property(14, String.class, "totalstocknum", false, "TOTALSTOCKNUM");
        public final static Property Totaloutnum = new Property(15, String.class, "totaloutnum", false, "TOTALOUTNUM");
    }

    private Query<DataList> inventory_DataListQuery;

    public DataListDao(DaoConfig config) {
        super(config);
    }
    
    public DataListDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"DATA_LIST\" (" + //
                "\"DID\" INTEGER," + // 0: did
                "\"HGSL\" TEXT," + // 1: hgsl
                "\"INVCODE\" TEXT," + // 2: invcode
                "\"INVNAME\" TEXT," + // 3: invname
                "\"GGXH\" TEXT," + // 4: ggxh
                "\"PCH\" TEXT," + // 5: pch
                "\"GYSPCH\" TEXT," + // 6: gyspch
                "\"BSTOCKID\" TEXT," + // 7: bstockid
                "\"BSTOCKNAME\" TEXT," + // 8: bstockname
                "\"BHWID\" TEXT," + // 9: bhwid
                "\"BHWNAME\" TEXT," + // 10: bhwname
                "\"MEANAME\" TEXT," + // 11: meaname
                "\"DDNUM\" TEXT," + // 12: ddnum
                "\"TOTALARRNUM\" TEXT," + // 13: totalarrnum
                "\"TOTALSTOCKNUM\" TEXT," + // 14: totalstocknum
                "\"TOTALOUTNUM\" TEXT);"); // 15: totaloutnum
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DATA_LIST\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, DataList entity) {
        stmt.clearBindings();
 
        Long did = entity.getDid();
        if (did != null) {
            stmt.bindLong(1, did);
        }
 
        String hgsl = entity.getHgsl();
        if (hgsl != null) {
            stmt.bindString(2, hgsl);
        }
 
        String invcode = entity.getInvcode();
        if (invcode != null) {
            stmt.bindString(3, invcode);
        }
 
        String invname = entity.getInvname();
        if (invname != null) {
            stmt.bindString(4, invname);
        }
 
        String ggxh = entity.getGgxh();
        if (ggxh != null) {
            stmt.bindString(5, ggxh);
        }
 
        String pch = entity.getPch();
        if (pch != null) {
            stmt.bindString(6, pch);
        }
 
        String gyspch = entity.getGyspch();
        if (gyspch != null) {
            stmt.bindString(7, gyspch);
        }
 
        String bstockid = entity.getBstockid();
        if (bstockid != null) {
            stmt.bindString(8, bstockid);
        }
 
        String bstockname = entity.getBstockname();
        if (bstockname != null) {
            stmt.bindString(9, bstockname);
        }
 
        String bhwid = entity.getBhwid();
        if (bhwid != null) {
            stmt.bindString(10, bhwid);
        }
 
        String bhwname = entity.getBhwname();
        if (bhwname != null) {
            stmt.bindString(11, bhwname);
        }
 
        String meaname = entity.getMeaname();
        if (meaname != null) {
            stmt.bindString(12, meaname);
        }
 
        String ddnum = entity.getDdnum();
        if (ddnum != null) {
            stmt.bindString(13, ddnum);
        }
 
        String totalarrnum = entity.getTotalarrnum();
        if (totalarrnum != null) {
            stmt.bindString(14, totalarrnum);
        }
 
        String totalstocknum = entity.getTotalstocknum();
        if (totalstocknum != null) {
            stmt.bindString(15, totalstocknum);
        }
 
        String totaloutnum = entity.getTotaloutnum();
        if (totaloutnum != null) {
            stmt.bindString(16, totaloutnum);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, DataList entity) {
        stmt.clearBindings();
 
        Long did = entity.getDid();
        if (did != null) {
            stmt.bindLong(1, did);
        }
 
        String hgsl = entity.getHgsl();
        if (hgsl != null) {
            stmt.bindString(2, hgsl);
        }
 
        String invcode = entity.getInvcode();
        if (invcode != null) {
            stmt.bindString(3, invcode);
        }
 
        String invname = entity.getInvname();
        if (invname != null) {
            stmt.bindString(4, invname);
        }
 
        String ggxh = entity.getGgxh();
        if (ggxh != null) {
            stmt.bindString(5, ggxh);
        }
 
        String pch = entity.getPch();
        if (pch != null) {
            stmt.bindString(6, pch);
        }
 
        String gyspch = entity.getGyspch();
        if (gyspch != null) {
            stmt.bindString(7, gyspch);
        }
 
        String bstockid = entity.getBstockid();
        if (bstockid != null) {
            stmt.bindString(8, bstockid);
        }
 
        String bstockname = entity.getBstockname();
        if (bstockname != null) {
            stmt.bindString(9, bstockname);
        }
 
        String bhwid = entity.getBhwid();
        if (bhwid != null) {
            stmt.bindString(10, bhwid);
        }
 
        String bhwname = entity.getBhwname();
        if (bhwname != null) {
            stmt.bindString(11, bhwname);
        }
 
        String meaname = entity.getMeaname();
        if (meaname != null) {
            stmt.bindString(12, meaname);
        }
 
        String ddnum = entity.getDdnum();
        if (ddnum != null) {
            stmt.bindString(13, ddnum);
        }
 
        String totalarrnum = entity.getTotalarrnum();
        if (totalarrnum != null) {
            stmt.bindString(14, totalarrnum);
        }
 
        String totalstocknum = entity.getTotalstocknum();
        if (totalstocknum != null) {
            stmt.bindString(15, totalstocknum);
        }
 
        String totaloutnum = entity.getTotaloutnum();
        if (totaloutnum != null) {
            stmt.bindString(16, totaloutnum);
        }
    }

    @Override
    public Void readKey(Cursor cursor, int offset) {
        return null;
    }    

    @Override
    public DataList readEntity(Cursor cursor, int offset) {
        DataList entity = new DataList( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // did
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // hgsl
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // invcode
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // invname
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // ggxh
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pch
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // gyspch
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // bstockid
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // bstockname
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // bhwid
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // bhwname
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // meaname
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // ddnum
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // totalarrnum
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // totalstocknum
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15) // totaloutnum
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, DataList entity, int offset) {
        entity.setDid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setHgsl(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setInvcode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setInvname(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setGgxh(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setPch(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setGyspch(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setBstockid(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setBstockname(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setBhwid(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setBhwname(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setMeaname(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setDdnum(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setTotalarrnum(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setTotalstocknum(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setTotaloutnum(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
     }
    
    @Override
    protected final Void updateKeyAfterInsert(DataList entity, long rowId) {
        // Unsupported or missing PK type
        return null;
    }
    
    @Override
    public Void getKey(DataList entity) {
        return null;
    }

    @Override
    public boolean hasKey(DataList entity) {
        // TODO
        return false;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "dataList" to-many relationship of Inventory. */
    public List<DataList> _queryInventory_DataList(Long did) {
        synchronized (this) {
            if (inventory_DataListQuery == null) {
                QueryBuilder<DataList> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.Did.eq(null));
                inventory_DataListQuery = queryBuilder.build();
            }
        }
        Query<DataList> query = inventory_DataListQuery.forCurrentThread();
        query.setParameter(0, did);
        return query.list();
    }

}
